package cn.ronghuanet.org.controller;

import cn.ronghuanet.auth.annotation.RonghuaPermission;
import cn.ronghuanet.basic.utils.AjaxResult;
import cn.ronghuanet.org.domain.Employee;
import cn.ronghuanet.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/employee")
@RonghuaPermission(name = "员工管理",descs = "员工管理")
public class EmployeeController {

    @Autowired
    private IEmployeeService employeeService;

    /**
     * 用来获取所有员工
     * @return
     */
    @GetMapping
    @RonghuaPermission(name = "查询所有",descs = "查询所有")
    public AjaxResult getAll(){
        try {
            List<Employee> lists = employeeService.getAll();
            return AjaxResult.me().setResultObj(lists);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        }
    }

}
